#ifndef RESPONSE_H
#define RESPONSE_H

#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
#include <QNetworkCookie>
#include <QString>
#include <QVariant>
#include <QNetworkReply>

class Response
{
public:
    Response();
    Response(QNetworkReply *reply);

    Response(int status);
    Response(int status, const QString &content, QVariantMap headers = QVariantMap());
    Response(int status, const QVariant &variant, QVariantMap headers = QVariantMap());
    Response(int status, const QByteArray &content, QVariantMap headers = QVariantMap());
    
    bool ok();
    int status();
    QByteArray content() const;

    int code();
    QString msg();
    QVariant data();

    QString toJson();
    QString toString();
    QVariantMap toMap();
    QVariantList toList();

    void setCookies(QList<QNetworkCookie> &cookies);
    QList<QNetworkCookie> cookies();

    qint64 headContentLength() const;

    QVariantMap headers() const;

    QString location() const;
    void setLocation(const QString &newLocation);

private:
    int m_status;
    QByteArray m_content;


    int m_code;
    QString m_msg;
    QVariant m_data;

    QJsonDocument m_document;
    QList<QNetworkCookie> m_cookies;
    QVariantMap m_headers;

    qint64 m_head_ContentLength;
    QString m_head_Location;
};

#endif // RESPONSE_H
